<?php 
include('../template/header.php');
include('../template/menuleft.php');
include('../template/menuright.php');

include '../config/DBConnect.php';
$sql="SELECT * FROM tbl_tang";
$query=mysql_query($sql);
$tang=array();
if (mysql_num_rows($query) > 0){

  while($rows=mysql_fetch_array($query)){
    $temp=array();
    $temp['id']=$rows['id'];
    $temp['tang']=$rows['tang'];
    array_push($tang,$temp);
  }
}

?>
<style type="text/css">
	fieldset, div.ktxr {
    text-align: center;
}
fieldset {
    border: 1px solid #CCCCCC;
    margin-top: 15px;
    padding: 15px;
}
fieldset input{
	margin: 10px;
	padding: 3px;
}
</style>
<script>
  function loadRoom(tang,khu)
  {
  var xmlhttp;
  if (window.XMLHttpRequest)
  {
    xmlhttp=new XMLHttpRequest();
  }
  else
  {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      document.getElementById("dsphong").innerHTML=xmlhttp.responseText;
    }
  }
 
xmlhttp.open("GET","get_all_room_by_floor.php?tang="+tang+"&khu="+khu,true);
xmlhttp.send();
}

function checkDangki(songuoi,mphong) {
	if (songuoi==8) {
		alert('Số người đã đạt tối đa vui lòng chọn phòng khác!');
	}else{
		location.href = 'kiemtradangki.php?maphong='+mphong;
	}
}
</script>
<div class="viewct" onclick="">
<fieldset class="danhsachtang">
	<legend>Chọn Tầng</legend>
	<?php for ($i=1; $i<=count($tang) ; $i++) { 
	 ?>
	<input type="button" size="4" value="T<?php echo $i; ?>" onclick="loadRoom(<?php echo $i; ?>,'<?php echo $_GET['khu'] ;?>')"/>
	<?php } ?>
</fieldset>
<div id="dsphong"></div>
</div>

<?php 
include('../template/footer.php');
?>
